//
//  FillLabel.m
//  Sample
//
//  Created by mac on 2017/9/15.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "FillLabel.h"

#define MAX_SIZE_HEIGHT 10000

@implementation FillLabel

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

        self.backgroundColor = RGB(236, 236, 236, 1);
        self.textColor = RGB(106, 106, 106, 1);
        self.font = [UIFont systemFontOfSize:FLEXIBLE(11)];
        self.textAlignment = NSTextAlignmentCenter;
        
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 2*Radio;
        self.layer.shouldRasterize = YES;
        self.layer.rasterizationScale = [UIScreen mainScreen].scale;
    }
    return self;
}

-(void)setRadius:(CGFloat)radius
{
    self.layer.cornerRadius = radius;
}

-(void)setText:(NSString *)text
{
    super.text = text;
    
    CGSize size = [[NSString stringWithFormat:@"%@**",self.text] sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:FLEXIBLE(11)]}];
    self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, size.width + 8, 15*Radio);
}

@end
